package org.yzz.auth.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.yzz.auth.annotation.RonghuaPermission;
import org.yzz.auth.domain.Permission;
import org.yzz.auth.query.PermissionQuery;
import org.yzz.auth.service.IPermissionService;
import org.yzz.base.utils.AjaxResult;
import org.yzz.base.utils.PageInfo;
import org.yzz.org.domain.Department;

import java.util.List;

@RestController
@RequestMapping("/permission")
@RonghuaPermission(name = "权限管理")
public class PermissionController {
    @Autowired
    private IPermissionService permissionService;

    @PutMapping
    public AjaxResult queryPage(@RequestBody PermissionQuery permissionQuery){
        try {
           PageInfo<Permission> list =permissionService.queryPage(permissionQuery);
           return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }
    @GetMapping
    @RonghuaPermission(name = "获取权限和其子权限")
    public AjaxResult queryPermission(){
        try {
            List<Permission> list = permissionService.queryPermission();
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }
}
